/**
 * @file ngclient.h
 * @author Suk Robert Koh (srkoh87z@gmail.com)
 *
 * @brief Abstract type of client to be extended
 */

#ifndef NGCLIENT_H_
#define NGCLIENT_H_

#include "../common/ngnetwork.h"
#include "../common/message/ngmessage.h"
#include "../common/message/ngmessagequeue.h"
#include "../common/message/ngmessagecoder.h"
#include "../common/message/ngdefaultmessagecoder.h"
#include "../common/utility/nglogger.h"
#include "../common/ngproperties.h"
#include "../common/ngtypes.h"

/**
 * @class	NGClient	Abstract type of client to be exnteded
 */
class NGClient
{
public:
	virtual int sendToServer(NGMessage *msg);

	void setMessageCoder(NGMessageCoder *_messageCoder);

	int getRecvQueueSize(void);
	NGMessage *getFirstMessage(void);

protected:
	NGClient();
	virtual ~NGClient();

	virtual BOOL handleRecv(void) = 0;
	virtual BOOL handleSend(void) = 0;

	SOCKET serverSocket;									/** Socket descriptor */
	NGMessageQueue *recvQueue;								/** Receive message queue */
	NGMessageQueue *sendQueue;								/** Send message queue */
	char *recvBuffer;										/** Temporary buffer to hold data received */
	int bufferPosition;										/** Current position in the recvBuffer */

	NGMessageCoder *messageCoder;							/** Message coder used for encoding/decoding messages */
};

#endif /* NGCLIENT_H_ */
